package whf.framework.log.events;

import org.hibernate.event.PreDeleteEvent;
import org.hibernate.event.PreDeleteEventListener;

import whf.framework.entity.Entity;
import whf.framework.log.util.AuditUtils;
import whf.framework.log.util.LogConfig;

/**
 * @author king
 * @create 2008-1-22 下午03:03:47
 * 
 */
@SuppressWarnings("serial")
public class HibernatePreDeleteEventListener implements PreDeleteEventListener {

	/* (non-Javadoc)
	 * @see org.hibernate.event.PreDeleteEventListener#onPreDelete(org.hibernate.event.PreDeleteEvent)
	 */
	public boolean onPreDelete(PreDeleteEvent event) {
		Entity entity = (Entity)event.getEntity();
		if(LogConfig.isHistoriable(entity.getClass())) {
			AuditUtils.getInstance().logDelete(null, entity);
		}
		return false;
	}

}
